<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="UserListForm">

        <p:panel header="#{bundle.ListUserTitle}">

            <p:dataTable id="datalist" value="#{userController.items}" var="item"
                         selectionMode="single" selection="#{userController.selected}"
                         rowKey="#{item.userId}"
                         paginator="true"
                         rows="10"
                         rowsPerPageTemplate="10,20,30"
                         >

                <p:ajax event="rowSelect"   update="createButton viewButton editButton deleteButton"/>
                <p:ajax event="rowUnselect" update="createButton viewButton editButton deleteButton"/>

                <p:column sortBy="#{item.userId}" filterBy="#{item.userId}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListUserTitle_userId}"/>
                    </f:facet>
                    <h:outputText value="#{item.userId}"/>
                </p:column>
                <p:column sortBy="#{item.email}" filterBy="#{item.email}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListUserTitle_email}"/>
                    </f:facet>
                    <h:outputText value="#{item.email}"/>
                </p:column>
                <p:column sortBy="#{item.password}" filterBy="#{item.password}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListUserTitle_password}"/>
                    </f:facet>
                    <h:outputText value="#{item.password}"/>
                </p:column>
                <p:column sortBy="#{item.firstName}" filterBy="#{item.firstName}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListUserTitle_firstName}"/>
                    </f:facet>
                    <h:outputText value="#{item.firstName}"/>
                </p:column>
                <p:column sortBy="#{item.lastName}" filterBy="#{item.lastName}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListUserTitle_lastName}"/>
                    </f:facet>
                    <h:outputText value="#{item.lastName}"/>
                </p:column>
                <p:column sortBy="#{item.gender}" filterBy="#{item.gender}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListUserTitle_gender}"/>
                    </f:facet>
                    <h:outputText value="#{item.gender}"/>
                </p:column>
                <p:column sortBy="#{item.address}" filterBy="#{item.address}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListUserTitle_address}"/>
                    </f:facet>
                    <h:outputText value="#{item.address}"/>
                </p:column>
                <p:column sortBy="#{item.country}" filterBy="#{item.country}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListUserTitle_country}"/>
                    </f:facet>
                    <h:outputText value="#{item.country}"/>
                </p:column>
                <p:column sortBy="#{item.role}" filterBy="#{item.role}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListUserTitle_role}"/>
                    </f:facet>
                    <h:outputText value="#{item.role}"/>
                </p:column>
                <f:facet name="footer">
                    <div class="footer-section">
                        <p:commandButton id="createButton" icon="ui-icon-plus"   value="#{bundle.Create}" actionListener="#{userController.prepareCreate}" update=":UserCreateForm" oncomplete="UserCreateDialog.show()"/>
                        <p:commandButton id="viewButton"   icon="ui-icon-search" value="#{bundle.View}" update=":UserViewForm" oncomplete="UserViewDialog.show()" disabled="#{empty userController.selected}"/>
                        <p:commandButton id="editButton"   icon="ui-icon-pencil" value="#{bundle.Edit}" update=":UserEditForm" oncomplete="UserEditDialog.show()" disabled="#{empty userController.selected}"/>
                        <p:commandButton id="deleteButton" icon="ui-icon-trash"  value="#{bundle.Delete}" actionListener="#{userController.delete}" update=":growl,datalist" disabled="#{empty userController.selected}"/>
                    </div>
                </f:facet>

            </p:dataTable>

        </p:panel>

    </h:form>

</ui:composition>